<%@ page import="aiball.History" %>

<!doctype html>
<html>
<head>
	<meta name="layout" content="main">
	<title>Bundesliga</title>
<script
	src="${GlobalConstants.URL_COMPLEATE}/static/plugins/jquery-1.7.1/js/jquery/jquery-1.7.1.min.js"
	type="text/javascript"></script>
<script
	src="${GlobalConstants.URL_COMPLEATE}/static/plugins/jquery-ui-1.8.15/jquery-ui/js/jquery-ui-1.8.15.custom.min.js"
	type="text/javascript"></script>
<script language="JavaScript">
		function datumLesen(){
			datum = document.getElementById('mySelect').value;
			window.location.href="../history/zeigeBundesliga?datum="+datum;
		}			

		$(document).ready(function() {

			$('#accordi').accordion();
			
			});
</script>
</head>

<body>
	<% if (params.datum == null) datum = aktuellesDatum else datum = params.datum %>
	<div id="bundesliga" class="content scaffold-create" role="main">
		<h1>Bundesliga - Saison ${datum}</h1>
		<br>
		<ol class="property-list playerStats">
		<li class="fieldcontain">
		Saison: <g:select id="mySelect" name="seasonSelectBox" from="${seasons}" onChange="datumLesen()" value="params.datum" noSelection="${['null':'andere anzeigen...']}"/>
        <br><br>  
        </li>
        <li class="fieldcontain">
		<%i=1%>	
		<g:set var="max" value="${maxSub[0]}" />
		<div id="accordi">
  		<g:while test="${i <= max}">
  		<h3 style="padding-left: 30px;">${i}. Bundesliga</h3>
    		<div>
				<table>
				<thead>
					<tr>
						<td>Platz</td>
						<td>Team</td>
						<td>Tore</td>
						<td>Gegentore</td>
						<td>Tor-Differenz</td>
						<td>Punkte</td>
					</tr>
				</thead>
				<tbody>
				<%platz=1%>
				<g:each in="${historyInstanceList}" status="j" var="historyInstance">
					<g:if test="${historyInstance.subLeague == i && historyInstance.time.toString() == (datum + " 00:00:00.0")}">
					<tr class="${(j % 2) == 0 ? 'even' : 'odd'}">
						<td>${platz}</td>
						<g:if test="${platz<=3 && i!=1}">
							<td><g:link style="color:#669933" title="Diese Mannschaft wird aufsteigen und kommende Saison in der nächst höheren Liga spielen!" controller="team" action="showOtherTeam" id="${historyInstance?.team?.id}">${historyInstance?.team?.name.encodeAsHTML()}</g:link></td>
						</g:if>
						<g:elseif test="${platz>=16 && i!=max}">
							<td><g:link style="color:#E65B1B" title="Diese Mannschaft wird absteigen und kommende Saison in der nächst tieferen Liga spielen!" controller="team" action="showOtherTeam" id="${historyInstance?.team?.id}">${historyInstance?.team?.name.encodeAsHTML()}</g:link></td>
						</g:elseif>
						<g:else>
							<td><g:link controller="team" action="showOtherTeam" id="${historyInstance?.team?.id}">${historyInstance?.team?.name.encodeAsHTML()}</g:link></td>
						</g:else>
						
						<td>${historyInstance.goalsSelf}</td>
						<td>${historyInstance.goalsOthers}</td>
						<td>${historyInstance.goalDiff}</td>
						<td>${historyInstance.points}</td>
					</tr>
					<%platz++%>
					</g:if>
				</g:each>
				</tbody>
				</table>
    		</div>
    		<%i++%>
		</g:while>	
		</div>
		<br>
		<br>
		</li>
		</ol>
		<div id="buttonsSaisonSpiele" class="content scaffold-create" role="main">
			<fieldset class="buttons">
				<g:link controller="gamecharts" action="showSeasonGames" params="[date: datum]">Zu den Spielergebnissen der Saison</g:link>
			</fieldset>
		</div>
	</div>

</body>
</html>